package org.hyl.javabase.集合扩展;

import java.util.ArrayList;
import java.util.List;

public class demo37 {
	
 static int curi=0;
 static int n=4;
 //0 1 2
 static int step=3;
 public static void main(String [] arg){
	 ArrayList<String> ll=new ArrayList<String>();
	
	 for(int i=0;i<n;i++){		
		 ll.add("s"+(i+1));
		 System.out.print("s"+(i+1)+" ");
	 }
	 System.out.println();
	 System.out.println(ll.size());
	 curi=2;
	 remove3(ll);
	
 }
 
 public static  void remove3(List<String> l){
	 if (l.size()<2 ) return ;	 

	 add2(l,2);	
	 l.remove(curi);	
	
	 if (curi>=l.size())
		 add2(l,curi-l.size());		

	 remove3(l);	 
 }
 public static void add2(List<String> l,int n){
	 if ((curi+n)<l.size() ) 	 
		  curi+=n;	 
		 else
		  curi=curi+n-l.size();
		
 }
}
